﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PowerSourceBehaviour : UnitBehaviour
{
    public PowerSource PS
    {
        get { return Unit as PowerSource; }
        set { Unit = value; }
    }

    public override void Init()
    {
        base.Init();
        var cnt = 9;

        var goe = NewChildObj("edge");
        var lr = goe.AddComponent<LineRenderer>();
        var pts = new Vector3[cnt];
        var a = 0f;
        var da = Mathf.PI * 2 / pts.Length;
        for (var i = 0; i < cnt; i++)
        {
            var r = 0.1f;
            var ir = new Vector3(Mathf.Cos(a), Mathf.Sin(a), 0);
            pts[i] = ir * r;
            a += da;
        }

        lr.loop = true;
        lr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        lr.startWidth = lr.endWidth = 0.1f;
        lr.startColor = lr.endColor = Color.red;
        lr.material = DefaultMaterial;
        lr.useWorldSpace = false;
        lr.positionCount = pts.Length;
        lr.SetPositions(pts);
    }
}
